package top.yxqz.spring.transaction.xml;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yxqz.spring.transaction.annotation.dao.BookDao;
import top.yxqz.spring.transaction.annotation.service.BookService;

/**
 * @author: 余小小
 * @date: 2023/4/20
 * @description：
 */
@Service("bookServicexml")
public class BookServiceImplXML implements BookService {

    @Autowired
    private BookDao bookDao;

    @Override
    public void buyBook(Integer userId, Integer bookId) {
//        得到图书价格
        Integer price = bookDao.getPriceByBook(bookId);
//        更新库存
        bookDao.updateStock(bookId);
//        更新用户余额
        bookDao.updateBalance(userId, price);

    }
}
